<%@ page language="java" contentType="text/html; charset=UTF-8"
   pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<meta charset="UTF-8">  
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">  
    <title>场馆定位</title>  
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=wDYEcxgRRheZwyC9jpN1Tt7fzr2zjosZ"></script>    
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script><!--调用jQuery-->  
  
    <style type="text/css">  
        body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}  
    </style>   
</head>
<body>
<div id="allmap"></div> 
</body>
</html>

<script type="text/javascript">    
  
    var map = new BMap.Map("allmap");    
    var point = new BMap.Point(116.709684,39.89778);  
    map.centerAndZoom(point, 16);    
    map.enableScrollWheelZoom();   
  
    var myIcon = new BMap.Icon("myicon.png",new BMap.Size(30,30),{  
        anchor: new BMap.Size(10,10)      
    });  
  
    var marker=new BMap.Marker(point,{icon: myIcon});    
    map.addOverlay(marker);    
  
    var geolocation = new BMap.Geolocation();  
    geolocation.getCurrentPosition(function(r){  
        if(this.getStatus() == BMAP_STATUS_SUCCESS){  
            var mk = new BMap.Marker(r.point);  
            map.addOverlay(mk);  
            //map.panTo(r.point);//地图中心点移到当前位置  
            var latCurrent = r.point.lat;  
            var lngCurrent = r.point.lng;  
            //alert('我的位置：'+ latCurrent + ',' + lngCurrent);  
  
            location.href="http://api.map.baidu.com/direction?origin="+latCurrent+","+lngCurrent+"&destination=114.144987,22.60506&mode=driving&region=深圳&output=html";  
  
        }  
        else {  
            alert('failed'+this.getStatus());  
        }          
    },{enableHighAccuracy: true})  
  
  
    map.addOverlay(marker);    
    var licontent="<b>悦动篮球馆</b><br>";    
        licontent+="<span><strong>地址：</strong>南湾街南岭社区龙山工业区16号（求水山公园西门,可园社区,南岭花园）</span><br>";    
        licontent+="<span><strong>电话：</strong>0755-84708976</span><br>";            
    var opts = {   
        width : 200,  
        height: 80,  
    };           
    var  infoWindow = new BMap.InfoWindow(licontent, opts);    
    marker.openInfoWindow(infoWindow);    
    marker.addEventListener('click',function(){  
        marker.openInfoWindow(infoWindow);  
    });    
  
</script> 